<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul {
            list-style: none;


        }

        * {
            margin: 0;
            padding: 0;
        }

        .content {
            width: 880px;
            height: 160px;
            margin: 0 auto;

            background-color: rgb(117, 117, 255);
        }

        ul li img {

            width: 200px;
            float: left;
            padding: 10px;
            /* margin: 10px; */
        }

        body {

            background: url(img/12换背景图片/1.jpg) no-repeat center top;
            background-size: cover;
        }
    </style>
</head>

<body>
    <div class="content">
        <ul class="baidu">
            <li><img src="img/12换背景图片/1.jpg"></li>
            <li><img src="img/12换背景图片/2.jpg"></li>
            <li><img src="img/12换背景图片/3.jpg"></li>
            <li><img src="img/12换背景图片/4.jpg"></li>
        </ul>

    </div>

    <script>
        var imgs = document.querySelectorAll("img");
        // console.log(imgs);
        for (var i = 0; i < imgs.length; i++) {
            imgs[i].onclick = function () {
                // console.log(this.src);
                document.body.style.backgroundImage = "url(" + this.src + ")";
            }

        }
    </script>
</body>

</html>